<?php
/**
 * 热门推荐
 *
 * HotRank.class.php
 * Created by IntelliJ IDEA.
 *
 * @author: hjh <hjh@jf.com>
 *
 * Date: 2017/10/28
 * Time: 10:48
 */

namespace Recommend;

class HotRank
{
    /**
     * @param int $viewCount
     * @param int $likeCount
     * @param int $disLikeCount
     * @param int $shareCount
     * @param int $commentCount
     * @param int $updateTime
     * @return float
     */
    public static function score($viewCount, $likeCount, $disLikeCount, $shareCount, $commentCount, $updateTime)
    {
        $T = (time() - strtotime($updateTime)) / 7200;
        //$T = max($T, 48);
        $z = 0.04;
        $s = 1 * $viewCount + 5 * ($likeCount - $disLikeCount) + 5 * $shareCount + 2 * $commentCount;
        return doubleval(log(max($s, 1))) * doubleval(exp(-1 * $z * max($T, 0)));
    }
}
